<script type="text/javascript">
$(function(){
	var pg = App.soagov.faceParam.ui, params = pg.params;
	var frm = {
		code: pg.seek('code'),
		name: pg.seek('name'),
		type: pg.seek('type'),
		len: pg.seek('len'),
		memo: pg.seek('memo')
	};
	function getValues(){
		return {
			id: params.id,
			faceId: params.faceId,
			code: frm.code.val(),
			name: frm.name.val(),
			type: frm.type.val(),
			flag: params.flag,
			len: frm.len.val(),
			memo: frm.memo.val()
		};
	}
	function setValues(o){
		pg.children('.title').html(o.key? '编辑接口':'添加接口');
		frm.code.val(o.code);
		frm.name.val(o.name);
		frm.type.val(o.type);
		frm.len.val(o.len);
		frm.memo.val(o.memo);
	}
	function valid(p){
		/* pg.find('.msg').html('');
		if(!p.code){
			frm.code.next().html('编号不能为空');
			return false;
		}
		if(!p.name){
			frm.name.next().html('名称不能为空');
			return false;
		} */
// 		if(/\w+(\.\w+)*/.test(p.code)){
// 			frm.code.next().html('接口名不符合要求');
//  			return false;
// 		}
		return true;
	}
	function validate(p){
		var x = App.validate, v = App.soagov.validation,
		msg=pg.seek('msg').html('');
		return x(v.svc.code, p.code, msg, '参数名') && x(v.svc.name, p.name, msg, '参数中文名');
	}
	$("input").blur(function(){
		var pms = getValues();
 		if(!validate(pms))
 			return;
	});
	pg.seek('ok').click(function(){
		var pms = getValues();
		if(!validate(pms))
			return;
		$.post(App.ctx + '/face/param/save.do', pms, function(rs){
			var ro = mac.eval(rs);
			if (ro.success) {
				pg.callback(ro.data);
				pg.close();
			} else {
				pg.seek('msg').html(mac.msg(ro.data, ro.params));
			}
		});
		return false;
	});

	if (params) {
		setValues(params);
	}
});
</script>
<style>
.faceParam .form .item>input {
	width: 260px;
}

.faceParam .form .item>textarea {
	width: 260px;
}
</style>
<div class="form">
	<div class="item">
		<span class="label">参数名：</span> <input type="text" name="code" /> <span
			class="msg">*</span>
	</div>
	<div class="item">
		<span class="label">参数中文名：</span> <input type="text" name="name" /> <span
			class="msg">*</span>
	</div>
	<div class="item">
		<span class="label">数据类型：</span> <input type="text" name="type" /> <span
			class="msg"></span>
	</div>
	<div class="item">
		<span class="label">长度：</span> <input type="text" name="len" /> <span
			class="msg"></span>
	</div>
	<div class="item">
		<span class="label">描述：</span>
		<textarea name="memo"></textarea>
		<span class="msg"></span>
	</div>
	<div class="item">
		<span class="label">&nbsp;</span>
		<div name="msg" class="msg"></div>
		<div class="clear"></div>
	</div>
	<div class="bottom">
		<button name="ok">保存</button>
	</div>
</div>